#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int N; int i, j;

struct Stu
{
	char name[25];
	int score;
	int j_score;
	char statue_gb;
	char statue_xb;
	int digit;
	int sum;
}student[110];

int compare(const void* p1, const void* p2)
{
	if (((struct Stu*)p1)->sum >= ((struct Stu*)p2)->sum)
		return -1;
	else     //if (((struct Stu*)p1)->sum < ((struct Stu*)p2)->sum)
		return 1;
}

long all_sum;
int main()
{
	cin >> N;
	for (i = 0; i < N; i++) {
		scanf("%s%d%d %c %c%d", student[i].name, &student[i].score, &student[i].j_score, &student[i].statue_gb, &student[i].statue_xb, &student[i].digit);
		if (student[i].score > 80 && student[i].digit >= 1)student[i].sum += 8000;
		if (student[i].score > 85 && student[i].j_score > 80)student[i].sum += 4000;
		if (student[i].score > 90)student[i].sum += 2000;
		if (student[i].score > 85 && student[i].statue_xb == 'Y')student[i].sum += 1000;
		if (student[i].j_score > 80 && student[i].statue_gb == 'Y')student[i].sum += 850;
		all_sum += student[i].sum;
	}
	qsort(student, N, sizeof(struct Stu), compare);
	cout << student[0].name << endl << student[0].sum << endl << all_sum;
	return 0;
}